﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace _054.UDP服务器端
{
	internal class Program
	{
		static void Main(string[] args)
		{
			// Dgram 点报
			Socket udpServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
			IPAddress iPAddress = new IPAddress(new byte[] { 10, 34, 200, 36 });
			// IP + Port
			IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, 7788);
			udpServer.Bind(iPEndPoint);
			// Any 任何人都可发送
			IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
			EndPoint ep = (EndPoint)ipep;
			byte[] data = new byte[1024];
			udpServer.ReceiveFrom(data, ref ep);
            Console.WriteLine("接受到的数据："+ Encoding.UTF8.GetString(data, 0, data.Length));


			udpServer.Close();

		}
	}
}
